package org.flashamaphone.voices.waveformFactories
{
	public class DualWaveFactory extends WaveFactory
	{
		/** wave 1 */
		protected var wave1:IWaveFactory;
		
		/** wave2 */
		protected var wave2:IWaveFactory;
		
		/** power of wave 1 */
		protected var power1:Number = .50;
		
		/** power of wave 2 */
		protected var power2:Number = .50;
		
		/**
		 * make a dual waveform
		 * 
		 * @param wave1
		 * @param wave2
		 * @param percent power of wave1
		 */
		public function DualWaveFactory( wave1:IWaveFactory, wave2:IWaveFactory, wave1percent:int = 50)
		{
			super();
			this.wave1 = wave1;
			this.wave2 = wave2;
			this.power1 = wave1percent/100;
			this.power2 = (100 - wave1percent)/100;
		}
		
		/**
		 * sample a dual wave at a phase
		 */
		public override function sample(phase:Number):Number {
			return wave1.sample(phase)*power1 + wave2.sample(phase)*power2;
		}
	}
}